package com.betterjr.modules.risk.api.service;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.betterjr.common.utils.Collections3;
import com.betterjr.common.web.AbstarctRemoteApiInvoke;
import com.betterjr.common.web.AjaxObject;
import com.betterjr.common.web.AjaxRemoteApiParam;
import com.betterjr.modules.agreement.service.ScfAgreementService;

@Service
public class RemoteApiCreateAgreementPDFItemInvokeService extends AbstarctRemoteApiInvoke {

    private String apiCode = "RAI00010";

    @Autowired
    private ScfAgreementService scfAgreementService;

    @Override
    public String saveOrFindInvoke(AjaxRemoteApiParam param) {

        return AjaxObject
                .newOk("查询成功", scfAgreementService.findPdfFileInfo(findProperties(param.getParamMap(), "appNo")))
                .toJson();
    }

    @Override
    public boolean supportInvoke(String anApiCode) {

        return apiCode.equals(anApiCode);
    }

    @Override
    public boolean checkParam(Map<String, Object> anParamMap) {

        boolean flag = true;

        if (flag && Collections3.isEmpty(anParamMap)) flag = false;

        if (flag && !anParamMap.containsKey("appNo")) flag = false;

        return flag;
    }

}
